/**
@author		Jong Min, Lee
@date		  01/21/2014
@brief		viewer property class

copyright(c) Tae Young Soft. All right reserved. 2014
*/
#pragma once

#include "Taurus_Util/Macros.h"
#include "Taurus_Viewer/IViewerProperty.h"

class CViewerProperty : public IViewerProperty
{
private:
  /**
  @brief		default constructor
  */
  CViewerProperty();

  DISALLOW_COPY_AND_ASSIGN(CViewerProperty);

public:
  /**
  @brief		destructor
  */
  ~CViewerProperty();

  /**
  @brief		get pointer to single instance of viewer property
  @return		pointer to single instance of viewer property
  */
  static CViewerProperty* getInstance();

  /**
  @brief		set property xml document
  @param		pPropertyDoc pointer to property xml document
  @return		ERROR_SUCCESS upon success, an error code otherwise
  */
  DWORD setProperty(MSXML2::IXMLDOMDocument2Ptr pPropertyDoc);


  /**
  @brief		get property by xpath
  @param		pszXPath pointer to xpath
  @return		pointer to property xml node if found, NULL if not
  */
  virtual MSXML2::IXMLDOMNodePtr getProperty(const TCHAR* pszXPath);

  /**
  @brief		update a property
  @param		pszParentName pointer to parent property name
  @param    pszName pointer to property name to be updated
  @param    pPropertyNode pointer to property node vluae
  @return		ERROR_SUCCESS upon success, an error codeo otherwise
  */
  virtual DWORD updateProperty(const TCHAR* pszParentName,
                               const TCHAR* pszName,
                               MSXML2::IXMLDOMNodePtr pPropertyNode);

  /**
  @brief		commit current viewer property
  @return		ERROR_SUCCESS upon success, an error codeo otherwise
  */
  virtual DWORD commit();

  /**
  @brief		rollback viewer property were updated previously
  @return		ERROR_SUCCESS upon success, an error codeo otherwise
  */
  virtual DWORD rollback();

private:
  /**
  @brief		destroy data members
  */
  void destroy();

private:
  //pointer to single instance
  static CViewerProperty* m_pInstance;

  //pointer to property xml document
  MSXML2::IXMLDOMDocument2Ptr m_pPropertyDoc;

  //flag indicating property should be committed
  BOOL m_bNeedCommit;
};
